﻿using System;
using System.Diagnostics.CodeAnalysis;

namespace AGR.Services
{
    public class ActionResult
    {
        /// <summary>
        /// boolean Success
        /// </summary>
        private bool success = false;

        /// <summary>
        /// boolean isSystemFailure
        /// </summary>
        private bool isSystemFailure = false;

        /// <summary>
        /// string ErrorMessage
        /// </summary>
        private string message = string.Empty;

        /// <summary>
        /// error Exception
        /// </summary>
        private Exception exception;

        /// <summary>
        /// integer sqlReturnRows
        /// </summary>
        private int sqlReturnRows = 0;

        /// <summary>
        /// decimal returnDecimalValue
        /// </summary>
        private decimal returnDecimalValue = 0;

        /// <summary>
        /// error message when deleted function called with dependencies
        /// </summary>
        private string deleteFailWithRelationship = "Other dependencies exist for this record and it can not be deleted.";

        /// <summary>
        /// Error message stating that insert was successful.
        /// </summary>
        private string recordInserted = "The record was inserted successfully.";

        /// <summary>
        /// generic error message
        /// </summary>
        private string genericErrorMessage = "A system error occured. Please retry your action.";

        /// <summary>
        /// Error message while deleting.
        /// </summary>
        private string genericDeleteErrorMessage = "An error occured whilst deleting record(s).";

        private string genericUpdateErrorMessage = "An error occured whilst updating record(s).";

        /// <summary>
        /// Error message while inserting.
        /// </summary>
        private string genericInsertErrorMessage = "An error occured whilst inserting your record.";

        /// <summary>
        /// Error message if a deleted unique constraint record exist.
        /// </summary>
        private string saveForUniqueErrorMessage = "Your action could not be completed. A similar inactive entity already exists. Please contact Administrator for assistance.";

        /// <summary>
        /// Error message on an insert if record exists.
        /// </summary>
        private string insertDuplicateErrorMessage = "The record already exists on the system.";

        private string recordReinstated = "The record was reinstated.";

        private string recordUpdated = "The record was updated successfully.";

        private string recordDeleted = "The record(s) was deleted successfully.";

        private string deleteSuccessErrorMessage = "The record was deleted successfully.";

        /// <summary>
        /// Enum - values possible when inserting or deleting records to the database.
        /// </summary>
        [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Added here as nested for easy accessibility over the system.")]
        public enum SaveChangesStatus
        {
            /// <summary>
            /// NULL value. No value or action to be taken.
            /// </summary>
            None,

            /// <summary>
            /// The record has been set to inactive. It should be re-instated.
            /// </summary>
            Reinstated,

            /// <summary>
            /// The record can be inserted into the database.
            /// </summary>
            Inserted,

            /// <summary>
            /// The record can be updated on the database.
            /// </summary>
            Updated,

            /// <summary>
            /// There exist a duplicate record on the database due to unique constraints. Record can not be inserted or updated.
            /// </summary>
            Duplicate,

            /// <summary>
            /// The record can be deleted from the database
            /// </summary>
            Deleted
        }

        /// <summary>
        /// Gets or sets
        /// </summary>
        public decimal ReturnDecimalValue
        {
            get { return returnDecimalValue; }
            set { returnDecimalValue = value; }
        }

        /// <summary>
        /// Gets or sets
        /// </summary>
        public int SqlReturnRows
        {
            get { return sqlReturnRows; }
            set { sqlReturnRows = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is systemfailure.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is systemfailure; otherwise, <c>false</c>.
        /// </value>
        public bool IsSystemFailure
        {
            get { return isSystemFailure; }
            set { isSystemFailure = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="ActionResult"/> is success.
        /// </summary>
        /// <value>
        /// <c>true</c> if success; otherwise, <c>false</c>.
        /// </value>
        public bool Success
        {
            get { return success; }
            set { success = value; }
        }

        /// <summary>
        /// Gets or sets
        /// </summary>
        public string Message
        {
            get { return message; }
            set { message = value; }
        }

        /// <summary>
        /// Gets or sets
        /// </summary>
        public Exception Exception
        {
            get { return exception; }
            set { exception = value; }
        }

        /// <summary>
        /// Gets error message: Other dependencies exist for this record and it can not be deleted.
        /// </summary>
        public string OnDeleteWithRelationship
        {
            get { return deleteFailWithRelationship; }
        }

        /// <summary>
        /// Gets error message: An error occured whilst deleting record(s).
        /// </summary>
        public string GenericDeleteErrorMessage
        {
            get { return genericDeleteErrorMessage; }
        }

        /// <summary>
        /// Gets error message: An error occured whilst deleting record(s).
        /// </summary>
        public string GenericAddErrorMessage
        {
            get { return genericInsertErrorMessage; }
        }

        public string GenericUpdateErrorMessage
        {
            get { return genericUpdateErrorMessage; }
        }

        /// <summary>
        /// Gets error message: An error occured.
        /// </summary>
        public string GenericErrorMessage
        {
            get { return genericErrorMessage; }
        }

        /// <summary>
        /// Gets error message: Your action could not be completed. A similar inactive entity already exist. Please contact Service Desk on 021 938 1111 or email ServiceDesk@tfg.co.za for assistance.
        /// </summary>
        public string OnSaveForUniqueErrorMessage
        {
            get { return saveForUniqueErrorMessage; }
        }

        /// <summary>
        /// Gets error message: The record already exists on the system.
        /// </summary>
        public string OnInsertDuplicateErrorMessage
        {
            get { return insertDuplicateErrorMessage; }
        }

        /// <summary>
        /// Gets the error message: This record was inserted
        /// </summary>
        public string RecordInserted
        {
            get { return recordInserted; }
        }

        /// <summary>
        /// Gets the error message: This record was inserted
        /// </summary>
        public string RecordReinstated
        {
            get { return recordReinstated; }
        }

        /// <summary>
        /// Gets the error message: This record was inserted
        /// </summary>
        public string DeleteSuccessErrorMessage
        {
            get { return deleteSuccessErrorMessage; }
        }
        /// <summary>
        /// Gets the error message: This record was inserted
        /// </summary>
        public string RecordUpdated
        {
            get { return recordUpdated; }
        }

        public string RecordDeleted
        {
            get { return recordDeleted; }
        }
    }
}
